package egs.strings;


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

 @SuppressWarnings("deprecation")
 public class  CountTag  {
	
	public static void main(String[] args) throws Exception
	{
		int c=0;
		String filename = "F://chandini//DivCount.txt";
		
	//@SuppressWarnings("deprecation")
	HttpClient client = new DefaultHttpClient();
	HttpGet request = new HttpGet("http://www.felight.com");
	HttpResponse response = client.execute(request);
	FileWriter f1 = new FileWriter(filename);
	BufferedWriter bw = new BufferedWriter(f1);
	// Get the response
	BufferedReader rd = new BufferedReader
	  (new InputStreamReader(response.getEntity().getContent()));
	    
	String line = " ";
	try {
		while ((line = rd.readLine()) != null) {
			//System.out.println(line);
			bw.write(line);
			bw.newLine();
			
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	bw.close();
	
	FileReader fr = new FileReader(filename);
	BufferedReader br = new BufferedReader(fr);
	while ((line =br.readLine())!= null)
	{  
		System.out.println(line);
			if(line.contains("type"))
				c++;
     }
	
	System.out.println(c);
	}
 }